﻿using Leo.Awesome.AppPlatform.Localization;
using Volo.Abp.Authorization.Permissions;
using Volo.Abp.Localization;
using static Leo.Awesome.AppPlatform.AppPlatfromApplcationContractsConsts;
namespace Leo.Awesome.AppPlatform.Permissions;

public class AppPlatformPermissionDefinitionProvider : PermissionDefinitionProvider
{
    public override void Define(IPermissionDefinitionContext context)
    {
        var menusGroup = context.AddGroup(DynamicMenusGroup);
        menusGroup.AddPermission(AppPlatformMenusCreate, L(AppPlatformMenusCreate));
        menusGroup.AddPermission(AppPlatformMenusUpdate, L(AppPlatformMenusUpdate));
        menusGroup.AddPermission(AppPlatformMenusDelete, L(AppPlatformMenusDelete));
        menusGroup.AddPermission(AppPlatformMenusView, L(AppPlatformMenusView));

        var codeRuleManagementGroup = context.AddGroup(CodeRuleManagementGroup);
        codeRuleManagementGroup.AddPermission(AppPlatformNumberRulesCreate, L(AppPlatformNumberRulesCreate));
        codeRuleManagementGroup.AddPermission(AppPlatformNumberRulesEdit, L(AppPlatformNumberRulesEdit));
        codeRuleManagementGroup.AddPermission(AppPlatformNumberRulesDelete, L(AppPlatformNumberRulesDelete));
        codeRuleManagementGroup.AddPermission(AppPlatformNumberRulesView, L(AppPlatformNumberRulesView));

        var platformDataDictionaryGroup = context.AddGroup(AppPlatformDataDictionaryGroup);
        platformDataDictionaryGroup.AddPermission(AppPlatformDataDictionaryCreate, L(AppPlatformDataDictionaryCreate));
        platformDataDictionaryGroup.AddPermission(AppPlatformDataDictionaryEdit, L(AppPlatformDataDictionaryEdit));
        platformDataDictionaryGroup.AddPermission(AppPlatformDataDictionaryDelete, L(AppPlatformDataDictionaryDelete));
        platformDataDictionaryGroup.AddPermission(AppPlatformDataDictionaryView, L(AppPlatformDataDictionaryView));

        var platformLoggingGroup = context.AddGroup(AppPlatformLoggingGroup);
        platformLoggingGroup.AddPermission(AppPlatformLoggingView, L(AppPlatformLoggingView));
    }

    private static LocalizableString L(string name)
    {
        return LocalizableString.Create<AppPlatformResource>(name);
    }
}
